<template>
  <div class="app-container">
    <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
      <el-form-item label="登录时间" prop="time">
        <el-date-picker
          v-model="formInline.time"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :picker-options="pickerDayStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item class="with-pre-select" label="IP" prop="ip">
        <el-input v-model="formInline.ip" class="input-with-select" @keyup.enter.native="handleFilter">         
        </el-input>
      </el-form-item>
      <el-form-item class="with-pre-select" label="网址" prop="domain">
        <el-input v-model="formInline.domain" class="input-with-select" @keyup.enter.native="handleFilter">         
        </el-input>
      </el-form-item>
      <el-form-item label="登录设备" prop="clientType">
        <el-select v-model="formInline.clientType" placeholder="请选择登录设备">
           <!--<el-option-->
            <!--:label="'全部'"-->
            <!--:key="consts.ALL"-->
            <!--:value="undefined"-->
          <!--&gt;</el-option>-->
          <el-option
            v-for="item in consts.DEVICE_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <el-button @click="cancel('formInline')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {resetForm,pickerOption} from '@/build'
  export default {
    name: "form-logs-filter",
    mixins:[resetForm,pickerOption],
    data() {
      return {
        formInline: {
          time: [moment(moment().startOf('month')).format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59'),],
          platform: undefined,
          ip: undefined,
          domain: undefined,
        },
      }
    },
    methods: {
      handleFilter(){
        this.$emit('on-filter',this.formInline)
      },
      cancel(formName){
        this.resetForm(formName)
        this.handleFilter()
      }
    },
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
